class RViewTemplate
  def initialize(view)
    @view = view
  end
  def render(template, assigns)
    env = Object.new
    def env.create_method(name, &block)
       self.class.send(:define_method, name, &block)
    end
    
    bind = env.send(:binding)
    
    @view.assigns.each do |key, value|
      env.instance_variable_set("@#{key}" , value)
    end
    assigns.each do |key, value|
      env.create_method(key) {value}
    end
    
    @view.controller.headers["Content-Type" ] ||= 'text/plain'
    
    template.split(/\n/).map{|line| eval(line, bind).to_s if line.strip }.join("\n")
  end
end